var fs = require('fs')

var arr = [{"name":"yuonly","password":"123123"},{"name":"lazhou","password":"2222222"}]
// 将数组转化为 json格式的数组字符串

var user = {"name":"zhangsan","password":"3333333"}

arr.push(user)

var arrJson = JSON.stringify(arr)
// 使用模板字符串拼接出 想要的字符串
var data = `var arr = ${arrJson}

module.exports = {
    users:arr
}`

// console.log(typeof data)
// console.log(data)
// 将拼接好的字符串写入 arr.js
fs.writeFile('./arr.js',data,function(err){
    if(!err){
        console.log('write db success')
    }
})